package com.zf.wms.purview.controller;

import com.zf.wms.purview.entity.DepartmentRole;
import com.zf.wms.purview.entity.Purview;
import com.zf.wms.purview.service.DepartmentRoleService;
import com.zf.wms.purview.service.PurviewService;
import com.zf.wms.purview.utils.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author：sl
 * Date：2019-11-05 11:40
 * Description：<描述>
 */
@RestController
@RequestMapping(value = "/purview")
public class PurviewController {

    @Autowired
    private PurviewService purviewService;

    @Autowired
    private DepartmentRoleService departmentRoleService;


    @Autowired

    @RequestMapping(value = "/allList", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultMap getList() {
        List<Purview> purviewList = purviewService.allList();
        return ResultMap.ok().put("purviewList", purviewList);
    }


    /**
     * 设置角色权限
     * @param departmentRole
     * @return
     */
    @RequestMapping(value = "/setRolePurview", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultMap insertRolePurview(DepartmentRole departmentRole) {
        departmentRoleService.save(departmentRole);
        return ResultMap.ok("设置成功");
    }


}
